#pragma once
#include "dllmain.h"
//#include "fuString.h"

//#define BOOST_DATE_TIME_NO_LIB
#include <boost/date_time.hpp>

BEGIN_NAMESPACE_CPPX

typedef boost::posix_time::time_duration::sec_type  fuSecond_t;
typedef boost::posix_time::time_duration::tick_type fuTimeTick_t;

class _CPPX_API fuTimeDiff
{
    boost::posix_time::time_duration m_diff;

public:
    fuTimeDiff(boost::posix_time::time_duration diff);
    fuSecond_t   toSeconds(void) const;
    fuTimeTick_t toMilliSeconds(void) const;
    fuTimeTick_t toMicroSeconds(void) const;
};

class _CPPX_API fuDateTime
{
    boost::posix_time::ptime m_time;

public:
    enum format_t {
        DT_FULL,
        DT_SECOND,
        DT_MINUTE,
        DT_HOUR,
        DT_DAY,
        DT_MONTH,
        DT_YEAR,
    };

public:
    fuDateTime(void);
    explicit fuDateTime(std::string time);
    explicit fuDateTime(boost::posix_time::ptime time);

    operator boost::posix_time::ptime (void) const;
    boost::posix_time::ptime get(void) const;

    static fuDateTime now(void);
    static fuDateTime begin(void);
    static fuDateTime end(void);

    fuDateTime & fromString(std::string str);

    std::string  toString(format_t fmt = DT_FULL) const;
    fuSecond_t   toSeconds(void) const;
    fuTimeTick_t toMilliSeconds(void) const;
    fuTimeTick_t toMicroSeconds(void) const;

    fuTimeDiff operator - (fuDateTime const & value);

    bool operator < (fuDateTime const & value) const;
    bool operator > (fuDateTime const & value) const;
};

END_NAMESPACE_CPPX
